/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo9282;

import java.io.*;
import java.util.*;

public class WordCount {
    // minimum number of occurrences needed to be printed

    public static final int OCCURRENCES = 1000;

    public static void main(String[] args)
            throws FileNotFoundException {
        

        // read the book into a map
        Scanner in = new Scanner(new File("e:/javalx/word3.txt"),"GBK");
        HashMap<String, Integer> wordCountMap =
                new HashMap<String, Integer>();
        while (in.hasNext()) {
            String w1 = in.next().toLowerCase();
            if (!wordCountMap.containsKey(w1)) {
                wordCountMap.put(w1, 1);
            } else {
                int count = wordCountMap.get(w1);
                wordCountMap.put(w1, count + 1);
            }
        }

        for (String word : wordCountMap.keySet()) {
            //System.out.println(word);
            int count = wordCountMap.get(word);
            
            
            if (count > OCCURRENCES) {
                System.out.println(word + " occurs "
                        + count + " times.");
            }
        }
    }
}
